<script setup>
import {updateApi} from "@/api/RoleAPI";
import MyForm from "@/components/MyForm.vue";
import {onMounted, shallowReactive, shallowRef} from "vue";
import {RULE} from "@/const";
import MyNav from "@/components/MyNav.vue";
import router from "@/router";
import {getResponseData} from "@/utils";
import {listApi} from "@/api/RoomAPI";

// 获取部门记录
let role = JSON.parse(sessionStorage.getItem('role'));

// 表单数据 + 表单规则
let optionItems = [];
let items = shallowRef([
  {'label': '角色标题', 'prop': 'title'},
  {'label': '角色描述', 'prop': 'info', 'type': 'textarea'},
]);
// 表单默认值
let data = shallowReactive({
  'id': role['id'],
  'title': role['title'],
  'info': role['info'] ? role['info'] : '暂无描述信息',
});
let rules = {
  'info': RULE.COMMON_INFO,
  'title': RULE.COMM_TITLE,
};

function success() {
  setTimeout(() => router.push('/Role'), 1000);
}

/*======================= 加载函数 ===========================*/

</script>

<template>

  <my-nav :items="[
    {'icon': 'User', 'label': '员工管理'},
    {'icon': 'User', 'label': '角色列表', 'url': '/Role'},
    {'icon': 'User', 'label': '修改角色'},
  ]"/>

  <el-divider/>
  <my-form type="update" width="65%"
           :span="1"
           :items="items"
           :data="data"
           :rules="rules"
           :api="updateApi"
           :fn="success"
  />


</template>

<style scoped lang="scss">
</style>